package com.itheima.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface MemberMapper {
    /**
     * 根据
     * @param yearDate
     */
    @Select("select count(id) from members where regTime<=#{yearDate}")
    Integer findMemberCountByYearDate(LocalDate yearDate);

    /**
     * 根据今天查询注册人数
     * @param today
     * @return
     */
    @Select("select count(id) from members where regTime=#{today}")
    Integer findMemberCountByToday(LocalDate today);
    @Select("select count(id) from members ")
    Integer findAllMember();

    /**
     *本周新增会员
     */
    @Select("select count(id) from members where yearweek(regTime,1) = yearweek(now(),1)")
    Integer findThisWeekNewMember();

    /**
     * 本月新增会员
     * @return
     */
    @Select("select count(id) from members where date_format(regTime,'%Y%m')=date_format(curdate(),'%Y%m')")
    Integer findThisMonthNewMember();
}
